const mongoose = require('mongoose');
// 连接数据库
mongoose.connect('mongodb://localhost/demo',{
    useNewUrlParser: true,
    useUnifiedTopology: true
});
const db = mongoose.connection;
db.on('error', console.error.bind(console, '数据库失败了，检查一下'));
db.once('open', function() {
  // we're connected!
  console.log('连接成功了')
})